using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_DealThem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            LoadDropDownList();
        }
    }
    protected void LoadDropDownList()
    {
        tbSanPhamCollection spCollection = tbSanPhamBUS.GetAll();
        ddl_sanpham.DataTextField = tbSanPhamColumns.TenSP.ToString();
        ddl_sanpham.DataValueField = tbSanPhamColumns.MaSP.ToString();
        ddl_sanpham.DataSource = spCollection;
        ddl_sanpham.DataBind();
        ddl_sanpham.Items.Insert(0, new ListItem("All", "0"));

        tbTinhTrangDealCollection ttdCollection = tbTinhTrangDealBUS.GetAll();
        ddl_tinhtrang.DataTextField = tbTinhTrangDealColumns.TenTTDEAL.ToString();
        ddl_tinhtrang.DataValueField = tbTinhTrangDealColumns.MaTTDEAL.ToString();
        ddl_tinhtrang.DataSource = ttdCollection;
        ddl_tinhtrang.DataBind();
        ddl_tinhtrang .Items .Insert (0,new ListItem ("All","0"));
    }
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            tbDeal  deal = new tbDeal ();
            deal.SanPham = int.Parse(ddl_sanpham.SelectedValue);
            deal.TinhTrang = int.Parse(ddl_tinhtrang.SelectedValue);
            tbDealBUS.Insert(deal);
            Response.Redirect("~/Admin/DealDanhSach.aspx");
        }
        catch (Exception ex)
        {

        }
        Response.Redirect("~/Admin/DealDanhSach.aspx");

    }
}
